/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package view;

import controller.ControllerInterface;
import imageviewerdb.ImageDb;
import imageviewerdb.ImageViewerModelInterface;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JFrame;

/**
 *
 * @author Daniel
 */
public class ImageMouseListener implements MouseListener {
    private JFrame ventana;
    private ControllerInterface controller;
    private ImageViewerModelInterface model;

    public ImageMouseListener(JFrame ventana, ControllerInterface controller, ImageViewerModelInterface model) {
        this.ventana = ventana;
        this.controller = controller;
        this.model = model;
    }
        

    public void mouseClicked(MouseEvent e) {
        if(e.getClickCount() == 2){
            ImageThumbnail img = (ImageThumbnail)e.getSource();
            ImageDb s = img.getImageDb();
            
            SliderDialog dialog = new SliderDialog(ventana, controller);                        
            dialog.setImagePath(img.getPath());            
            dialog.setTextName(s.getName());
            dialog.setTextCat(s.getTopic());

            if(s.getConfidentiality())
                dialog.setTextConf("true");
            else
                dialog.setTextConf("false");

            dialog.setTextSize(s.getSize());
            dialog.setImages(model.getPictures(), img.getPos(), model.getNumberOfTuples("pictures"));
            dialog.showDialog();       
        }
    }

    public void mousePressed(MouseEvent e) {
        //throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mouseReleased(MouseEvent e) {
        //throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mouseEntered(MouseEvent e) {
        //System.out.println("Entered");
        ImageThumbnail img = (ImageThumbnail)e.getSource();
        img.drawSquare(true);
        img.repaint();
        //throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mouseExited(MouseEvent e) {
        //System.out.println("Exited");
        ImageThumbnail img = (ImageThumbnail)e.getSource();
        img.drawSquare(false);
        img.repaint();
        //throw new UnsupportedOperationException("Not supported yet.");
    }

}
